package org.tuestudent.grouppa;

import java.io.IOException;

import junit.framework.TestCase;

import org.junit.Before;
import org.tuestudent.grouppa.TCPClient;

public class TCPClientTest extends TestCase {

    private TCPClient instance;

    public void setUp() throws Exception {
        instance =TCPClient.getInstance();
    }

    public void compressionTest(String message) throws IOException {
        byte[] compressed = instance.compressMessage(message);
        String decompressed = instance.decompressMessage(compressed);
        assertEquals(message, decompressed);
    }

    public void testCompressed0() throws IOException {
        compressionTest("");
    }

    public void testCompressed1() throws IOException {
        compressionTest("a");
    }

    public void testCompressed2() throws IOException {
        compressionTest("casdfasd_Dsa");
    }

    public void testCompressed3() throws IOException {
        compressionTest("{" + "\"fromController\":\"\"," + "\"id\":0,"
                + "\"responseToId\":0," + "\"serializedArguments\":\"blabla\","
                + "\"toController\":\"\"," + "\"toTask\":\"\"}");
    }

    public void compressEncryptTest(String message) throws Exception {
        byte[] compressedEncrypted = instance.compressEncryptMessage(message);
        String result = instance.decryptDecompressMessages(compressedEncrypted);
        assertEquals(message, result);
    }

    public void testEncryptedCompressed0() throws Exception {
        compressEncryptTest("");
    }

    public void testEncryptedCompressed1() throws Exception {
        compressEncryptTest("a");
    }

    public void testEncryptedCompressed2() throws Exception {
        compressEncryptTest("casdfasd_Dsa");
    }

    public void testEncryptedCompressed3() throws Exception {
        compressEncryptTest("{" + "\"fromController\":\"\"," + "\"id\":0,"
                + "\"responseToId\":0," + "\"serializedArguments\":\"blabla\","
                + "\"toController\":\"\"," + "\"toTask\":\"\"}");
    }
    
    
}
